package com.runchen.broadcastdetection.mvp.home;

import com.runchen.broadcastdetection.entity.DeviceInfo;
import com.ruochen.common.base.ApiCallback;
import com.ruochen.common.base.BasePage;
import com.ruochen.common.base.BasePresenter;

/**
 * @Description 登录 MVP Presenter
 * @Auth RuoChen
 * @Date 04/04/2021, 14:20
 **/
public class MainPresenter extends BasePresenter<MainCovenant.MvpView, MainCovenant.MvpStores>
        implements MainCovenant.Presenter {

    public MainPresenter(MainCovenant.MvpView view) {
        attachView(view);
    }

    @Override
    public void getDeviceList() {
        mvpView.showLoading("正在搜索设备");
        addSubscription(appStores.getDeviceList("",
                "",
                "",
                2, ""),
                new ApiCallback<BasePage<DeviceInfo>>(mvpView) {
                    @Override
                    public void onSuccess(BasePage<DeviceInfo> model) {
                        mvpView.hide();
                        mvpView.onGetDeviceListSuccess(model);
                    }

                    @Override
                    public void onFailure(int code, String msg) {
                        mvpView.hide();
                        mvpView.onGetDeviceListFailure(code, msg);
                    }
                });
    }
}